﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chowpoo.Sql;
using CourseSystem.Core.Entities;
using CourseSystem.Core.SqlServerDAL;

namespace CourseSystem.Core.BLL
{
    public class ExaminationItemBLL : CommonBLL<ExaminationItemInfo, ExaminationItemDAL>
    {
        public static IQueryable<ExaminationItemInfo> GetList(int eid, int type)
        {
            var re = GetList();
            re = re.Where(o => o.Eid == eid);
            if (type != -1)
                re = re.Where(o => o.QuestionLibInfo.Type == type);
            return re;
        }

        public static IQueryable<ExaminationItemInfo> GetList(int itemId)
        {
            var re = GetList();
            re = re.Where(o => o.Qid == itemId);
            return re;
        }

        public static ExaminationItemInfo Get(int id)
        {
            using (var dal = new ExaminationItemDAL())
            {
                var re = dal.SelectSingle(o => o.Id == id);
                return re;
            }
        }

        public static bool Del(int id)
        {
            using (var dal = new ExaminationItemDAL())
            {
                return dal.Delete(o => o.Id == id) != null;
            }
        }

    }
}
